using System;
using System.IO;
using JetBrains.Annotations;

namespace YAFTS.Contracts
{
	public sealed class FileContentChangedArgs : EventArgs
	{
		private readonly Func<string, TextReader> _openContentStream;

		public FileContentChangedArgs([NotNull] string fileName, [NotNull] Func<string, TextReader> openContentStream)
		{
			_openContentStream = openContentStream;
			if (fileName == null)
			{
				throw new ArgumentNullException("fileName");
			}
			if (openContentStream == null)
			{
				throw new ArgumentNullException("openContentStream");
			}

			FileName = fileName;
		}

		public string FileName { get; private set; }

		public TextReader GetContenStream()
		{
			return _openContentStream(FileName);
		}
	}
}